package com.meshnetics.gb.stack.core.event.system;

import com.meshnetics.gb.stack.core.event.StackEvent;
import com.meshnetics.gb.stack.core.event.StackEventType;
import com.meshnetics.gb.Context;

/**
 * Parent for all system events. Its type is StackEventType.SYSTEM_TYPE
 *
 * @author mmarkov
 */
public class SystemStackEvent extends StackEvent {
    /** System code of the event. */
    protected int code;

    /**
     * Constructs SystemStackEvent having the given name, code and no Context.
     *
     * @param name the name of SystemStackEvent
     * @param code system code of SystemStackEvent
     */
    public SystemStackEvent(String name, int code) {
        this(name, code, null);
    }

    /**
     * Constructs SystemStackEvent having the given name, code and context.
     *
     * @param name the name of SystemStackEvent
     * @param code system code of SystemStackEvent
     * @param ctx the Context of SystemStackEvent (could be null)
     */
    public SystemStackEvent(String name, int code, Context ctx) {
        super(name, StackEventType.SYSTEM_TYPE, ctx);
        this.code = code;
    }

    /**
     * Returns system code of the event.
     *
     * @return system code of the event
     */
    public int getSystemCode() {
        return code;
    }
}
